#include "KeyPointAssociation.h"

KeyPointAssociation::KeyPointAssociation(){type = keypoint_association;}

KeyPointAssociation::KeyPointAssociation(KeyPoint * a, KeyPoint * b, float desc_dist, float limit){
	p1=a;
	p2=b;
	type = keypoint_association;
	weight = (limit-desc_dist)/limit;
	//printf("desc_dist = %f, limit = %f, weight = %f\n",desc_dist,limit,weight);
}

KeyPointAssociation::KeyPointAssociation(KeyPoint * a, KeyPoint * b){
	p1=a;
	p2=b;
	type = keypoint_association;
}


KeyPointAssociation::~KeyPointAssociation(){}

float KeyPointAssociation::compatable(Association *  asso){

	if(asso->type == keypoint_association){
		KeyPointAssociation * a = (KeyPointAssociation *)asso;
		if(p1 == a->p1 || p2 == a->p2){
			return -1;
		}
		//float diff = fabs(p1->point->square_distance(a->p1->point) - p2->point->square_distance(a->p2->point));
		return 10.0f*fabs(p1->point->distance(a->p1->point) - p2->point->distance(a->p2->point));
	}else{
		return -2;
	}
}
